using Common;
using Framework;
using System;

public class AppController : Controller<AppView>
{
    private string _curScene;

    protected override void Init()
    {
        _curScene = StaticData.HomeScene;
        AddModuleListener<string>(GlobalEvent.LoadScene, OnLoadScene);
    }

    private void OnLoadScene(string sceneName)
    {
        if (sceneName == _curScene) return;

        SceneTool.Instance.LoadScene(sceneName);
        if (sceneName == StaticData.HomeScene)
        {
            view.LoadScene(true);
            ModuleManager.HideModule(_curScene);
            _curScene = StaticData.HomeScene;
        }
        else
        {
            view.LoadScene(false); ;
            ModuleManager.ShowModule(sceneName);
            _curScene = sceneName;
        }
    }
}
